import axios from 'axios'

// 登录注册
export function login(account, pwd) {
  const url = '/users/login'
  const param = {
    userAccount: account,
    userPwd: pwd
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}
// 注册
export function register (account, pwd) {
  const url = '/users/register'
  const param = {
    userAccount: account,
    userPwd: pwd
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}

// 获取热门搜索
export function getHotSearch() {
  const url = '/'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}

// 预约理疗api
export function getPhysiatrics () {
  const url = '/getPhysiatric'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch(((err) => {
    console.log(err)
  }))
}

// 预约体检api
export function getExamination () {
  const url = '/getExamination'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch(((err) => {
    console.log(err)
  }))
}

// 养老院接口
export function getBeadhouses () {
  const url = '/getBeadHouses'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch(((err) => {
    console.log(err)
  }))
}
// 生成订单
export function createOrder (param) {
  const  url = '/setOrder'
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}
// 获取订单
export function getOrders () {
  const url = '/getorders'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch(((err) => {
    console.log(err)
  }))
}
// 删除订单
export function delOrder(id) {
  const  url = '/delOrder'
  const param = {
    orderId: id
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}
